<?php
namespace BP\En;
class UAC {
	public $IsInsert;	// boolean
	public $IsDelete;	// boolean
	public $IsUpdate;	// boolean
	public $IsView;	// boolean
	public $IsAdjunct;	// boolean
	public $IsExp;	// boolean
	public $IsImp;	// boolean
	private function __init() { // default class members
		$this->IsInsert =  FALSE ;
		$this->IsDelete =  FALSE ;
		$this->IsUpdate =  FALSE ;
		$this->IsView =  TRUE ;
		$this->IsAdjunct =  FALSE ;
		$this->IsExp =  FALSE ;
		$this->IsImp =  FALSE ;
	}
	public function LoadRightFromCCGPM ($en) // [Entity en]
	{
		$sql = (((("SELECT Tag1  FROM V_GPM_EmpMenu WHERE  FK_Emp='" . $WebUser->getNo()) . "'  AND Url LIKE '%") . $en) . "%'  ");
		$dt = DBAccess->RunSQLReturnTable($sql);
		foreach ($dt->Rows as $dr) 		{
			$tag = $dr->getValue(0);
			if (($tag->contains("Insert") ==  TRUE ))
			{
				$this->IsInsert =  TRUE ;
			}
			if (($tag->contains("Update") ==  TRUE ))
			{
				$this->IsUpdate =  TRUE ;
			}
			if (($tag->contains("Delete") ==  TRUE ))
			{
				$this->IsDelete =  TRUE ;
			}
		}
	}
	public function Readonly () 
	{
		$this->IsUpdate =  FALSE ;
		$this->IsDelete =  FALSE ;
		$this->IsInsert =  FALSE ;
		$this->IsAdjunct =  FALSE ;
		$this->IsView =  TRUE ;
	}
	public function OpenAll () 
	{
		$this->IsUpdate =  TRUE ;
		$this->IsDelete =  TRUE ;
		$this->IsInsert =  TRUE ;
		$this->IsAdjunct =  FALSE ;
		$this->IsView =  TRUE ;
	}
	public function OpenAllForStation ($fk_station) // [String fk_station]
	{
		$ps = new Paras();
		$ps->Add("user", $WebUser->getNo());
		$ps->Add("st", $fk_station);
		$bl = null;
		$bl = DBAccess->IsExits((((("SELECT FK_Emp FROM Port_DeptEmpStation WHERE FK_Emp=" . $SystemConfig->getAppCenterDBVarStr()) . "user AND FK_Station=") . $SystemConfig->getAppCenterDBVarStr()) . "st"), $ps);
		if ($bl)
		{
			$this->OpenAll();
		}
		else
		{
			$this->Readonly();
		}
	}
	public function OpenForSysAdmin () 
	{
		if ($WebUser->getNo()->equals("admin"))
		{
			$this->OpenAll();
		}
		return $this;
	}
	public function OpenForAppAdmin () 
	{
		if ((($WebUser->getNo() != NULL) && ($WebUser->getNo()->contains("admin") ==  TRUE )))
		{
			$this->OpenAll();
		}
		return $this;
	}
	public static function constructor__ () 
	{
		$me = new self();
		$me->__init();
		return $me;
	}
}
?>
